/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ticketmaster.businesslogic;

import java.util.Collection;
import ticketmaster.dao.DAOFactory;
import ticketmaster.dao.EventDAO;
import ticketmaster.dataobject.Event;

/**
 *
 * @author Varadha
 */
public class EventController
{

    private EventDAO eventDAO = DAOFactory.getInstance().getEventDAO();

    public int addEvent(Event event)
    {

        Event sEvent = new Event();

        sEvent.setName(event.getName());

        Collection<Event> eventCollection = eventDAO.getEventsDO(event);
        int newid = 0;

        if (!eventCollection.isEmpty())
        {
            return 0;
        }
        else
        {
            newid = eventDAO.insertEvent(event);
            if (newid == 0)
            {
                return 0;
            }
            else
            {
                return newid;
            }
        }

    }

    public boolean deleteEvent(Event event)
    {
        return eventDAO.delete(event);

    }

    public Collection<Event> getAllEvents()
    {
        EventDAO eventDAO = DAOFactory.getInstance().getEventDAO();
        Event event = new Event();
        return eventDAO.getEventsDO(event);
    }

    public Collection<Event> getEvents(Event event)
    {
        EventDAO eventDAO = DAOFactory.getInstance().getEventDAO();
        return eventDAO.getEventsDO(event);
    }
}
